<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			//5. 根据课件动物类的例子，尝试动物飞的方法，然后子类进行重写，实现多态。
			function Animal(type) {
				this.type = type;
			}
			Animal.prototype.fly = function() {
				console.log(this.type + this.name + "启动起飞")
			}

			function F() {}
			F.prototype = Animal.prototype;

			function Bird(name) {
				Animal.call(this, "小鸟")
				this.name = name;
			}
			Bird.prototype = new F();
			Bird.prototype.constructor = Bird;
			Bird.prototype.fly = function() {
				console.log(this.type + this.name + "拍打着翅膀飞行")
			}
			let bird = new Bird("洛洛");
			console.log(bird);
			bird.fly();
			
			function Bat(name){
				Animal.call(this, "蝙蝠")
				this.name = name;
			}
			Bat.prototype = new F();
			Bat.prototype.constructor = Bat;
			Bat.prototype.fly = function() {
				console.log(this.type + this.name + "靠翼膜来飞行")
			}
			let bat = new Bat("浮浮");
			console.log(bat);
			bat.fly();
			
			function Bee(name){
				Animal.call(this, "蜜蜂")
				this.name = name;
			}
			Bee.prototype = new F();
			Bee.prototype.constructor = Bee;
			Bee.prototype.fly = function() {
				console.log(this.type + this.name + "借助翅膀和腿飞行")
			}
			let bee = new Bee("小弥");
			console.log(bee);
			bee.fly();
		</script>
	</body>
</html>
